﻿namespace Sidvall.AuthorizationManager.UI.Entities.ConfigModel
{
    public class ResourceFactory : global::Sidvall.Data.IResourceFactory
    {
        #region CreateItem

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItem(string resource, Sidvall.Data.DataRowState? dataRowState)
        {
            switch (resource)
            {
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.UserConfiguration:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.UserConfiguration(dataRowState);
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.ServerConnection:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.ServerConnection(dataRowState);
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.ResourceOption:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.ResourceOption(dataRowState);
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.ActionOption:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.ActionOption(dataRowState);
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.AuthorizationContext:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.AuthorizationContext(dataRowState);
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.Claim:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.Claim(dataRowState);
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.FilterContext:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.FilterContext(dataRowState);
                default:
                    return null;
            }
        }
        
        #endregion
        #region CreateItems
        
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItems(string resource)
        {
            switch (resource)
            {
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.UserConfiguration:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.UserConfigurationCollection();
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.ServerConnection:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.ServerConnectionCollection();
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.ResourceOption:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.ResourceOptionCollection();
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.ActionOption:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.ActionOptionCollection();
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.AuthorizationContext:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.AuthorizationContextCollection();
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.Claim:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.ClaimCollection();
                case global::Sidvall.AuthorizationManager.Data.ConfigModel.DomainObjects.FilterContext:
                    return new global::Sidvall.AuthorizationManager.UI.Entities.FilterContextCollection();
                default:
                    return null;
            }
        }
        
        #endregion
        
        #region Current

        private static readonly System.Lazy<ResourceFactory> _Current = new System.Lazy<ResourceFactory>(() => new ResourceFactory());
        public static ResourceFactory Current
        {
            get
            {
                return _Current.Value;
            }
        }

        #endregion
    }
}